package 力扣日常刷题.木22二月.第13天219;

/**
 * @author 帅小伙
 * @date 2022/2/19
 * @description 绳子必须分成两段
 */
public class Demo93剪绳子 {

    public int cuttingRope(int n) {
        if (n <= 3) return n - 1;
        int a = n / 3, b = n % 3;
        if (b == 0) return (int) Math.pow(3, a);
        if (b == 1) return (int) Math.pow(3, a - 1) * 4;
        return (int) Math.pow(3, a) * 2;
    }

}

